package com.example.thread;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * TODO
 *
 * @author qibao
 * @version v0.1 2020/12/16
 */
public class ThreadPoolDemo {
    public static final LinkedBlockingQueue queue = new LinkedBlockingQueue();
    public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 10, 1L, TimeUnit.MINUTES, queue);

    public static void main(String[] args) {
        while (threadPoolExecutor.getActiveCount() < 5){
            threadPoolExecutor.execute(() -> {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName());
            });
        }
    }

}
